package com.lewis.module.m2.api.luck.api;

import com.lewis.common.core.entity.BaseResult;
import com.lewis.module.m2.api.luck.service.ILuckService;
import com.lewis.module.m2.api.luck.entity.Luck;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 运势表 前端控制器
 * </p>
 *
 * @author lewis
 * @since 2021-12-01
 */
@Api(tags = "运势")
@RestController
@RequestMapping("/api/luck")
public class LuckApi {

	@Resource
	private ILuckService luckService;

	@ApiOperation(value = "运势api")
	@GetMapping("/getLuck")
	public BaseResult getLuck(String qq, String groupId) {
		return luckService.getLuck(qq, groupId);
	}

	@ApiOperation(value = "随机获取一个普通运势")
	@GetMapping("/getRandomOne")
	public Luck getRandomOne() {
		return luckService.getRandomOne();
	}

	@ApiOperation(value = "根据id获取运势")
	@GetMapping("/getById")
	public Luck getById(Integer id) {
		return luckService.getById(id);
	}

	// @ApiOperation(value = "初始化ini配置文件")
	// @GetMapping("/init")
	// public boolean init() {
	// 	IniUtils.init("D:\\Temp\\数据.ini");
	// 	for (Object o : IniUtils.sections.keySet()) {
	// 		Properties o1 = (Properties)IniUtils.sections.get(o);
	// 		String level = String.valueOf(o1.get("签名"));
	// 		String simple = String.valueOf(o1.get("签文"));
	// 		String content = String.valueOf(o1.get("解签文"));
	// 		Luck luck = new Luck();
	// 		luck.setLevel(level);
	// 		luck.setSimple(simple);
	// 		luck.setContent(content);
	// 		if (!luckService.save(luck)) {
	// 			return false;
	// 		}
	// 	}
	// 	return true;
	// }
}
